package swingxrcp.framework.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class PropertiesUtils {

	private PropertiesUtils() {}

	public static Properties loadFromClassPath(String path) throws IOException {
		Properties properties = new Properties();
		try {
			properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(path));
		} catch (NullPointerException e) {
			throw new FileNotFoundException("加载配置失败，配置路径：" + path);
		}
		return properties;
	}

	public static Properties loadFromFileSystem(String path) throws IOException {
		Properties properties = new Properties();
		try {
			properties.load(new FileInputStream(new File(path)));
		} catch (NullPointerException e) {
			throw new FileNotFoundException("加载配置失败，配置路径：" + path);
		}
		return properties;
	}

}
